#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;
void solve()
{
    ll n;ll k;
    cin >> n;
    cin >> k;
    vector<ll> a(n+1);
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin() + 1, a.end());
    ll l = a[(n - k + 1) / 2], r = a[(n + k + 2) / 2];
    cout << r - l + 1 << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
